// $ANTLR 3.1.3 Mar 18, 2009 10:09:25 XHTML2CSVTree.g 2009-10-13 16:08:20

import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

public class XHTML2CSVTree extends TreeParser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "CELLULEG", "CELLULED", "LIGNEG", "LIGNED", "TABLED", "LIGNE", "TABLEAU", "CELLULE", "TABLEALIGN", "BORDER", "ENTIER", "FINBALISE", "GUILLEMET", "POS", "CHAINE", "WHITESPACE"
    };
    public static final int LIGNED=7;
    public static final int LIGNEG=6;
    public static final int LIGNE=9;
    public static final int CELLULEG=4;
    public static final int CELLULED=5;
    public static final int TABLEALIGN=12;
    public static final int WHITESPACE=19;
    public static final int CHAINE=18;
    public static final int EOF=-1;
    public static final int TABLEAU=10;
    public static final int BORDER=13;
    public static final int GUILLEMET=16;
    public static final int POS=17;
    public static final int ENTIER=14;
    public static final int TABLED=8;
    public static final int CELLULE=11;
    public static final int FINBALISE=15;

    // delegates
    // delegators


        public XHTML2CSVTree(TreeNodeStream input) {
            this(input, new RecognizerSharedState());
        }
        public XHTML2CSVTree(TreeNodeStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        

    public String[] getTokenNames() { return XHTML2CSVTree.tokenNames; }
    public String getGrammarFileName() { return "XHTML2CSVTree.g"; }


    				// variables and methods to be included in the java file generated



    // $ANTLR start "tableau"
    // XHTML2CSVTree.g:18:1: tableau returns [String csv] : ^( TABLEAU lignes ) ;
    public final String tableau() throws RecognitionException {
        String csv = null;

        try {
            // XHTML2CSVTree.g:18:30: ( ^( TABLEAU lignes ) )
            // XHTML2CSVTree.g:18:32: ^( TABLEAU lignes )
            {
            match(input,TABLEAU,FOLLOW_TABLEAU_in_tableau45); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_lignes_in_tableau47);
            lignes();

            state._fsp--;


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "tableau"


    // $ANTLR start "lignes"
    // XHTML2CSVTree.g:20:1: lignes returns [String csv] : l1= ligne l2= lignes2 ;
    public final String lignes() throws RecognitionException {
        String csv = null;

        String l1 = null;

        String l2 = null;


        try {
            // XHTML2CSVTree.g:20:29: (l1= ligne l2= lignes2 )
            // XHTML2CSVTree.g:20:31: l1= ligne l2= lignes2
            {
            pushFollow(FOLLOW_ligne_in_lignes62);
            l1=ligne();

            state._fsp--;

            pushFollow(FOLLOW_lignes2_in_lignes66);
            l2=lignes2();

            state._fsp--;

             csv = l1 + "\n" + l2 ;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "lignes"


    // $ANTLR start "lignes2"
    // XHTML2CSVTree.g:22:1: lignes2 returns [String csv] : (l1= ligne l2= lignes2 | );
    public final String lignes2() throws RecognitionException {
        String csv = null;

        String l1 = null;

        String l2 = null;


        try {
            // XHTML2CSVTree.g:22:30: (l1= ligne l2= lignes2 | )
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0==LIGNE) ) {
                alt1=1;
            }
            else if ( (LA1_0==UP) ) {
                alt1=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 1, 0, input);

                throw nvae;
            }
            switch (alt1) {
                case 1 :
                    // XHTML2CSVTree.g:22:32: l1= ligne l2= lignes2
                    {
                    pushFollow(FOLLOW_ligne_in_lignes282);
                    l1=ligne();

                    state._fsp--;

                    pushFollow(FOLLOW_lignes2_in_lignes286);
                    l2=lignes2();

                    state._fsp--;

                     csv = l1 + "\n" + l2 ;

                    }
                    break;
                case 2 :
                    // XHTML2CSVTree.g:22:91: 
                    {
                     csv = "" ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "lignes2"


    // $ANTLR start "ligne"
    // XHTML2CSVTree.g:24:1: ligne returns [String csv] : ^( LIGNE cellules ) ;
    public final String ligne() throws RecognitionException {
        String csv = null;

        try {
            // XHTML2CSVTree.g:24:28: ( ^( LIGNE cellules ) )
            // XHTML2CSVTree.g:24:30: ^( LIGNE cellules )
            {
            match(input,LIGNE,FOLLOW_LIGNE_in_ligne105); 

            match(input, Token.DOWN, null); 
            pushFollow(FOLLOW_cellules_in_ligne107);
            cellules();

            state._fsp--;


            match(input, Token.UP, null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "ligne"


    // $ANTLR start "cellules"
    // XHTML2CSVTree.g:26:1: cellules returns [String csv] : (c1= cellule c2= cellules | c1= cellule );
    public final String cellules() throws RecognitionException {
        String csv = null;

        String c1 = null;

        String c2 = null;


        try {
            // XHTML2CSVTree.g:26:31: (c1= cellule c2= cellules | c1= cellule )
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==CELLULE) ) {
                int LA2_1 = input.LA(2);

                if ( (LA2_1==DOWN) ) {
                    int LA2_2 = input.LA(3);

                    if ( (LA2_2==CHAINE) ) {
                        int LA2_3 = input.LA(4);

                        if ( (LA2_3==UP) ) {
                            int LA2_4 = input.LA(5);

                            if ( (LA2_4==UP) ) {
                                alt2=2;
                            }
                            else if ( (LA2_4==CELLULE) ) {
                                alt2=1;
                            }
                            else {
                                NoViableAltException nvae =
                                    new NoViableAltException("", 2, 4, input);

                                throw nvae;
                            }
                        }
                        else {
                            NoViableAltException nvae =
                                new NoViableAltException("", 2, 3, input);

                            throw nvae;
                        }
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 2, 2, input);

                        throw nvae;
                    }
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 2, 1, input);

                    throw nvae;
                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;
            }
            switch (alt2) {
                case 1 :
                    // XHTML2CSVTree.g:26:33: c1= cellule c2= cellules
                    {
                    pushFollow(FOLLOW_cellule_in_cellules122);
                    c1=cellule();

                    state._fsp--;

                    pushFollow(FOLLOW_cellules_in_cellules126);
                    c2=cellules();

                    state._fsp--;

                     csv = "\"" + c1 + ", " + c2 ;

                    }
                    break;
                case 2 :
                    // XHTML2CSVTree.g:26:102: c1= cellule
                    {
                    pushFollow(FOLLOW_cellule_in_cellules134);
                    c1=cellule();

                    state._fsp--;

                     csv = "\"" + c1 ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "cellules"


    // $ANTLR start "cellule"
    // XHTML2CSVTree.g:28:1: cellule returns [String csv] : ^( CELLULE s= CHAINE ) ;
    public final String cellule() throws RecognitionException {
        String csv = null;

        CommonTree s=null;

        try {
            // XHTML2CSVTree.g:28:30: ( ^( CELLULE s= CHAINE ) )
            // XHTML2CSVTree.g:28:32: ^( CELLULE s= CHAINE )
            {
            match(input,CELLULE,FOLLOW_CELLULE_in_cellule149); 

            match(input, Token.DOWN, null); 
            s=(CommonTree)match(input,CHAINE,FOLLOW_CHAINE_in_cellule153); 

            match(input, Token.UP, null); 
             csv = (s!=null?s.getText():null); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "cellule"

    // Delegated rules


 

    public static final BitSet FOLLOW_TABLEAU_in_tableau45 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_lignes_in_tableau47 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ligne_in_lignes62 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_lignes2_in_lignes66 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ligne_in_lignes282 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_lignes2_in_lignes286 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LIGNE_in_ligne105 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_cellules_in_ligne107 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_cellule_in_cellules122 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_cellules_in_cellules126 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_cellule_in_cellules134 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CELLULE_in_cellule149 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_CHAINE_in_cellule153 = new BitSet(new long[]{0x0000000000000008L});

}